import numpy as np
import matplotlib.pyplot as plt
import matplotlib
from mulClassifiers import data, sigmoid
from scipy.io import loadmat

weight = loadmat("/home/wdd/Desktop/ML_CODE/NeualWork/ex3weights.mat")
theta1, theta2 = weight['Theta1'], weight['Theta2']
# print(theta1.shape, theta2.shape)

# 插入常数项
X2 = np.matrix(np.insert(data['X'], 0, values=np.ones(data['X'].shape[0]), axis=1))
y2 = np.matrix(data['y'])

print(X2.shape, y2.shape)

a1 = X2
z2 = a1 * theta1.T
print(z2.shape)

a2 = sigmoid(z2)
print(a2.shape)

a2 = np.insert(a2, 0, values=np.ones(a2.shape[0]), axis=1)
z3 = a2 * theta2.T
print(z3.shape)

a3 = sigmoid(z3)
print(a3)

y_pred2 = np.argmax(a3, axis=1) + 1
print(y_pred2)